package co.uk.j_wp.games.topdowngame.tile;

import java.util.Arrays;

import co.uk.j_wp.games.topdowngame.Game;
import co.uk.j_wp.games.topdowngame.Screen;

public class Tile {

	protected int color = -1;
	private boolean passable;

	public static final int TILE_ABOVE = 0;
	public static final int TILE_RIGHT = 1;
	public static final int TILE_BELOW = 2;
	public static final int TILE_LEFT = 3;

	public int[] colors;

	public Tile() {

	}

	public Tile(int color) {
		this.color = color;
	}

	public Tile(int[] image) {
		// this.colors = new int[Game.TILE_SIZE*Game.TILE_SIZE];
		// image.getData().getPixels(0, 0, image.getWidth(), image.getHeight(),
		// this.colors);
		
		this.colors = Arrays.copyOfRange(image, 0, Game.TILE_SIZE*Game.TILE_SIZE);
	}

	public void tick() {

	}

	public void draw(Screen s, Tile[] l, int xo, int yo) {
		if (colors != null && colors.length != Game.TILE_SIZE * Game.TILE_SIZE) {
			s.setPixels(Game.TILE_SIZE, Game.TILE_SIZE, xo, yo, color);
		} else {
			s.setPixels(Game.TILE_SIZE, Game.TILE_SIZE, xo, yo, colors, false);
		}
	}

	public void setColor(int color) {
		this.color = color;
	}

	public int getColor() {
		return color;
	}

	public void setPassable(boolean b) {
		this.passable = b;
	}

	public boolean isPassable() {
		return passable;
	}
}
